﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace WoSoft.PACS.Utility
{
    /// <summary>
    /// 数据表处理扩展
    /// </summary>
    public static class DataTableExtend
    {
        /// <summary>
        /// 根据字段名称取字段内容值 
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        public static object GetColumnValue(this DataTable dt, string columnName)
        {
            if (dt == null || dt.Rows.Count == 0) return null;

            if (dt.Columns.Contains(columnName))
            {
                return dt.Rows[0][columnName];
            }

            return null;
        }
    }
}
